/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.adcc.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vn.adcc.dao.ContractDao;
import vn.adcc.model.Contract;
import vn.adcc.service.ContractManager;

/**
 *
 * @author ducanh.nguyen
 */
@Service("contractManager")
public class ContractManagerImpl extends GenericManagerImpl<Contract, Integer> implements ContractManager {
    private ContractDao contractDao;

    /**
     * @return the contractDao
     */
    public ContractDao getContractDao() {
        return contractDao;
    }

    /**
     * @param contractDao the contractDao to set
     */
    @Autowired
    public void setContractDao(ContractDao contractDao) {
        this.contractDao = contractDao;
        this.dao = contractDao;
    }

    public List<Contract> search(String query) {
        return super.search(query, Contract.class);
    }

    public boolean isExists(String contractCodeToCheck) {
        Map<String,Object> params = new HashMap<String, Object>();
        params.put("contractCode", contractCodeToCheck);
        return contractDao.findByNamedQuery("Contract.findByContractCode", params).isEmpty()? false:true;
    }
}
